<?php
require 'template/header.php';
?>

<!--container-->
<?php

?>
<div id="container">
    <!--Left panel-->
    <div id="left-panel">

        <!-- Left box-->
        <div class="left-stuff">

            <!--Side header-->
            <h3>DANH MỤC SẢN PHẨM</h3>
            <ul id="left-menu">
                <li><a href="#">Bếp gas dương</a>
                    <ul class="list-menu">
                        <li><a href="#">Menu #1</a></li>
                        <li><a href="#">Menu #2</a></li>
                        <li><a href="#">Menu #3</a></li>
                        <li><a href="#">Menu #4</a></li>
                        <li><a href="#">Menu #5</a></li>
                    </ul>
                </li>
                <li><a href="#">Bếp gas âm</a>
                    <ul class="list-menu">
                        <li><a href="#">Menu #1</a></li>
                        <li><a href="#">Menu #2</a></li>
                        <li><a href="#">Menu #3</a></li>
                        <li><a href="#">Menu #4</a></li>
                        <li><a href="#">Menu #5</a></li>
                    </ul>
                </li>
                <li><a href="#">Máy hút khử mùi</a></li>
                <li><a href="#">Bếp điện từ</a></li>
                <li><a href="#">Chậu rửa bát</a></li>
                <li><a href="#">Bếp gas âm</a></li>
                <li><a href="#">Máy hút khử mùi</a></li>
                <li><a href="#">Bếp điện từ</a></li>
                <li><a href="#">Chậu rửa bát</a></li>
                <li><a href="#">Bếp gas âm</a></li>
                <li><a href="#">Máy hút khử mùi</a></li>
                <li><a href="#">Bếp điện từ</a></li>
                <li><a href="#">Chậu rửa bát</a></li>
                <li><a href="#">Bếp gas âm</a></li>
                <li><a href="#">Máy hút khử mùi</a></li>
                <li><a href="#">Bếp điện từ</a></li>
                <li><a href="#">Chậu rửa bát</a>
                    <ul class="list-menu">
                        <li><a href="#">Menu #1</a></li>
                        <li><a href="#">Menu #2</a></li>
                        <li><a href="#">Menu #3</a></li>
                        <li><a href="#">Menu #4</a></li>
                        <li><a href="#">Menu #5</a></li>
                    </ul>
                </li>
            </ul>
        </div>	
    </div>
    <div id="content">
        <div class="cart">
            <h1>Giỏ hàng</h1>
            <?php
            $conn = mysql_connect('localhost', 'root', '');
            mysql_select_db('bepgas_db', $conn);
            $giohang = $_SESSION['cart'];
            if (count($giohang)) {
                ?>
            <form action="" method="post">
                    <?php
                    $tongcong = 0;
                    foreach ($giohang as $idproduct => $sl) {

                        $sql =$query="select tbl_products.pro_id,name,price,url from tbl_products inner join tbl_images on tbl_products.pro_id=tbl_images.pro_id where tbl_products.pro_id in ('$idproduct')";
                        $result = mysql_query($sql);
                        $r = mysql_fetch_row($result);
                        ?>
                         <table border="1">
                <tr align="center">
                    <th>Sản phẩm</th>
                    <th>Số lượng</th>
                    <th>Thành tiền</th>
                    <th>Xóa</th>
                </tr>
                <tr>                                    
                    <td align="center" bgcolor="#FFFFFF">                                              
                        <a href=""><img src="<?php
                            echo $r[3];
                        ?>" border="0" height="88"></a><br />
                        <a href="" style="color:#006699; font-weight:bold"><?php
                            echo $r[1];
                        ?></a><br /><br />                                              
                        <span style="color:#FF0000; font-size:16px; font-weight:bold;"><?php
                            
                            echo number_format($r[2], 0, ',', '.') . " VNĐ";
                        ?></span><br>
                    </td>
                    <td align="center" bgcolor="#FFFFFF" valign="middle" width="110">
                        <input name="quantity_1480" style="width:80px;" value="<?php
                            echo $sl;
                        ?>" id="quantity_1480" type="text">
                        <input value="Cập nhật" type="button">

                    </td>
                    <td style="font-weight:bold; color:#FF0000; text-align:center; width: 150px"  bgcolor="#FFFFFF">
                        <?php
                            echo number_format(($sl*$r[2]),0,',','.'). " VNĐ";
                        ?></td>
                    <td align="center" bgcolor="#FFFFFF" valign="middle" width="105">
                        <a href='deleteCart.php?id_sp=<?php
                            echo $r[0];
                            ?>'><input type="button" value="Xóa"></a>
                    </td>
                </tr>
                <?php
                        $tongcong+=$sl*$r[2];
                    }
                
                ?>
                <tr>
                    <td colspan="4" style="font-weight:bold; text-transform:uppercase; color:#000000;" align="right" bgcolor="#FFFFFF">
                        Tổng cộng:
                        <span id="total" style="font-weight:bold; color:#FF0000"><?php
                            echo number_format($tongcong,0,',','.'). " VNĐ";
                        ?></span></td>                                
                </tr>
                <tr>
                    <td colspan="4" align="right"><input value="Tiếp tục mua hàng" onclick="" type="button">
                        <input value="Đặt hàng" onclick="" type="button">
                        <a href="deleteCart.php?id_sp=0"><input type="button" value="Xóa giỏ hàng"></a>
                    </td>
                </tr>
            </table>
                        
            </form>
            <?php
            }
            ?>
        </div>
    </div>
</div>

<?php
require 'template/footer.php';
?>